package day06;

import java.util.Arrays;

public class Exercise {
    public static void main(String[] args) {
        int[] arr1 = new int[3];
        for (int i = 0; i < arr1.length; i++) {
            arr1[i] = (int) (Math.random() * 40);
            System.out.println(arr1[i]);
        }
        int max = arr1[0];
        for (int i = 0; i < arr1.length; i++) {
            if (arr1[i] > max) {
                max = arr1[i];
            }
        }
        System.out.println("最大值为"+max);

        Arrays.copyOf(arr1,arr1.length+1);//扩容
        arr1[arr1.length]=max;
        for (int i = 0; i <arr1.length ; i++) {
            System.out.println(arr1[i]);
        }


        say();
        sayHi("李舟君");
        sayHello("李舟君", 24);
        sayHello("李舟君", 45);
        System.out.println(getNum());
        int a1 = 4, a2 = 5;
        int d = plus(a1, a2);
        System.out.println(d);
        int[] array = testArray(5, 20);

        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + "\t");
        }
        System.out.println("");
        Arrays.sort(array);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + "\t");
        }
        System.out.println("");


    }

    public static void say() {
        System.out.println("你好，我叫李舟君");
    }

    public static void sayHi(String name) {
        System.out.println("你好，我叫" + name);
    }

    public static void sayHello(String name, int age) {
        if (age > 30) {
            return;
        }
        System.out.println("你好，我叫" + name + ",今年" + age + "岁了");
    }

    public static int getNum() {
        return 10;
    }

    public static int plus(int a, int b) {
        int c = a + b;
        return c;
    }

    public static int[] testArray(int num, int range) {
        int[] arr = new int[num];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * range);
        }
        return arr;
    }


}
